package yxxy.c_026;

import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class T09_SingleThreadPool {
    public static void main(String[] args) {
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        for(int i=0; i<5; i++) {
            final int j = i;
            executorService.execute(()->{

                System.out.println(j + " " + Thread.currentThread().getName());
            });
        }
       /* Random r = new Random();
        int t = 0;
        int f = 0;
        for (int i = 0; i < 1000000000; i++) {
            boolean b = r.nextBoolean();
            if (b == true){
                t++;
            }else{
                f++;
            }
        }
        System.out.println("true:"+t);
        System.out.println("false:"+f);*/
    }
}
